package com.hl.sfzy.controller;

import com.hl.sfzy.entity.Course;
import com.hl.sfzy.entity.CourseDetail;
import com.hl.sfzy.entity.CourseList;
import com.hl.sfzy.service.CourseListService;
import com.hl.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CourseListController
 * @Description TODO
 * @Author 野原新之助
 * @Date 2024年01月16日 8:42:54
 * @Version 1.0
 */
@CrossOrigin
@RestController
@RequestMapping({"/course_list"})
public class CourseListController {
    @Autowired
    private CourseListService courseListService;
    @PutMapping({"/edit"})
    public Result edit(@RequestBody CourseList courseList) {
        this.courseListService.edit(courseList);
        return Result.success();
    }
    @GetMapping({"/find/{id}"})
    public Result findById(@PathVariable Integer id) {
        return Result.success(this.courseListService.findById(id));
    }

    @GetMapping({"/find"})
    public Result findPage(@RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize, CourseList courseList) {
        return Result.success(this.courseListService.findPage(pageNum, pageSize, courseList));
    }
}
